/**
 * 
 * @authors Wang Guangzhou (wang6756@163.org)
 * @date    2016-11-04 13:11:40
 * @version $Id$
 */

var path = require('path');
var config = require('./server/config');
var projectRoot = path.resolve(__dirname);

function getEntryMap() {
    var entryArr = [
        'admin/index',
        'admin/overview/room',
        'admin/setting/area',
        'admin/setting/floorArea',
        'admin/login'
    ];
    var entryMap = {};
    entryArr.forEach(function(key) {
        entryMap[key] = ['./client/javascript/' + key + '.js'];
    });
    return entryMap;
}

module.exports = {
  entry: getEntryMap(),
  output: {
    path: path.resolve(__dirname, './public'), //config.build.assetsRoot,
    publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
    filename: 'js/[name].js'
  },
  resolve: {
    extensions: ['.js', '.vue', '.json'],
    alias: {
      'vue$': 'vue/dist/vue',
    }
  },
  module: {
    loaders: [
      {
        test: /\.vue$/,
        loader: 'vue-loader'
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        include: projectRoot,
        exclude: '/node_modules/'
      },
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader'
      },
      {
        test: /\.(eot|svg|ttf|woff|woff2)(\?\S*)?$/,
        loader: 'url-loader?limit=8192&name=fonts/[name].[hash:8].[ext]'
      },
      {
        test: /\.(png|jpe?g|gif|svg)(\?\S*)?$/,
        loader: 'url-loader?limit=8192&name=images/[name].[hash:8].[ext]'
      }
    ]
  }
};